package com.eloisa.gls.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.eloisa.gls.domain.User;

@Repository
public class UserDao extends GenericDao<User, Integer> implements IUserDao {

	public User getUser(String account, String uuid) {
//		User user = new User();
//		user.setAccount(account);
//		user.setUuid(uuid);
//		List list = this.getHibernateTemplate().findByExample(user);
//
//		if (list != null && list.size() > 0)
//			return (User) list.get(0);
//		return null;

		DetachedCriteria dc = DetachedCriteria.forClass(persistentClass);
		dc.add(Restrictions.eq("account", account));
		dc.add(Restrictions.eq("uuid", uuid));

		List list = getHibernateTemplate().findByCriteria(dc);
		if (list != null && list.size() > 0)
			return (User) list.get(0);
		return null;

	}
}
